{% extends "user_profile/user.html" %}
<!-- user_moderate.html -->
{% block profilesection %}
    {% trans %}moderation{% endtrans %}
{% endblock %}
{% block usercontent %}
{% if request.user != view_user %}
    <h3 style="margin-bottom: 0.5em">{% trans username=view_user.username|escape, status=view_user.get_status_display() %}{{username}}'s current status is "{{status}}"{% endtrans %}
    </h3>
    {% if user_status_changed %}
        <p class="action-status"><span>{{ user_status_changed_message }}</span></p>
    {% endif %}
    <form method="post" class="moderate-pane">{% csrf_token %}
        <input class="normal-btn" type="hidden" name="sort" value="moderate"/>
        <table class="form-as-table">
        {{ change_user_status_form.as_table() }}
        </table>
        <p id="id_user_status_info"></p>
        <p>
            <input class="normal-btn" type="submit" name="change_status" value="{% trans %}Change status{% endtrans %}" />
            {% if not view_user.is_blocked() %}
            <input class="normal-btn" type="submit" name="hard_block" value="{% trans %}Block user and delete all content{% endtrans %}" />
            {% endif %}
        </p>
    </form>
{% endif %}
<h3 style="margin-bottom: 1em; line-height: 1.2em">
{% if request.user == view_user %}
    {% trans reputation=view_user.reputation %}Your current reputation is {{reputation}} points{% endtrans %}
{% else %}
    {% trans reputation=view_user.reputation %}User's current reputation is {{reputation}} points{% endtrans %}
{% endif %}
</h3>
{% if user_rep_changed %}
    <p class="action-status"><span>{% trans %}User reputation changed{% endtrans %}</span></p>
{% endif %}
<form method="post" class="moderate-pane">{% csrf_token %}
    <input class="normal-btn" type="hidden" name="sort" value="moderate"/>
    <table class="form-as-table">
    {{ change_user_reputation_form.as_table() }}
    </table>
    <input class="normal-btn" type="submit" name="subtract_reputation" value="{% trans %}Subtract{% endtrans %}" />&nbsp;
    <input class="normal-btn" type="submit" name="add_reputation" value="{% trans %}Add{% endtrans %}" />
</form>
{% if request.user != view_user %}
<hr/>
<h3 style="margin-bottom: 0.5em">{% trans username=view_user.username|escape %}Send message to {{username}}{% endtrans %}</h3>
<p>{% trans %}An email will be sent to the user with 'reply-to' field set to your email address. Please make sure that your address is entered correctly.{% endtrans %}</p>
    {% if message_sent %}
        <p class="action-status"><span>{% trans %}Message sent{% endtrans %}</span></p>
    {% endif %}
<form method="post" class="moderate-pane">{% csrf_token %}
    <input class="normal-btn" type="hidden" name="sort" value="moderate"/>
    <div class="form-row-vertical">
    <label for="id_subject_line">{{ send_message_form.subject_line.label}}</label>
    {% if send_message_form.subject_line.errors %}
        <p class="error">{{send_message_form.subject_line.errors|join(', ')}}</p>
    {% endif %}
    {{ send_message_form.subject_line}}
    </div>
    <div class="form-row-vertical">
    <label for="id_body_text">{{ send_message_form.body_text.label}}</label>
    {% if send_message_form.body_text.errors %}
        <p class="error">{{send_message_form.body_text.errors|join(', ')}}</p>
    {% endif %}
    {{ send_message_form.body_text}}
    </div>
    <input class="normal-btn" type="submit" name="send_message" value="{% trans %}Send message{% endtrans %}" />
</form>
{% endif %}
{% endblock %}
{% block sidebar %}{% endblock %}
{% block endjs %}
    <script type="text/javascript" >
        $("#id_user_status_info").hide();
        $("#id_user_status").change(function () {
            var optionValue = $(this).attr('value');
            if (optionValue == "d") {
                $('#id_user_status_info').html("{% trans %}Administrators have privileges of normal users, but in addition they can assign/revoke any status to any user, and are exempt from the reputation limits.{% endtrans %}");
                $('#id_user_status_info').show('slow');
            } else if (optionValue == "m"){
                $('#id_user_status_info').html("{% trans %}Moderators have the same privileges as administrators, but cannot add or remove user status of 'moderator' or 'administrator'.{% endtrans %}");
                $('#id_user_status_info').show('slow');
            } else if (optionValue == "a"){
                $('#id_user_status_info').html("{% trans %}'Approved' status means the same as regular user.{% endtrans %}");
                $('#id_user_status_info').show('slow');
            } else if (optionValue == "s"){
                $('#id_user_status_info').html("{% trans %}Suspended users can only edit or delete their own posts.{% endtrans %}");
                $('#id_user_status_info').show('slow');
            } else if (optionValue == "b"){
                $('#id_user_status_info').html("{% trans %}Blocked users can only login and send feedback to the site administrators, their url and profile will also be hidden.{% endtrans %}");
                $('#id_user_status_info').show('slow');
            } else {
                $('#id_user_status_info').hide('slow');
            }
        })
        $('input[name="hard_block"]').click(function() {
            $('input[name="delete_content"]').val('true');
            $('select[name="user_status"]').val('b');
        });
    </script>
{% endblock %}
